<?php
	$fields_arr = array(
		'order_no'=>'订单号',
		'amount'=>'总金额(￥)',
		'actual_amount'=>'应付金额(￥)',
		'payway'=>'支付方式',
		'shippingway'=>'配送方式',
		'order_time'=>'下单时间',
		'orderstatus'=>'订单状态',
		'operation'=>'操作',
	);
	if(!$custom_field_arr){
		$custom_field_arr = array_flip($fields_arr);
	}
	$fields_arr_new = array_merge($custom_field_arr,array_flip($fields_arr));
	$fields_arr_new = array_unique($fields_arr_new);
?>
{include app:admin.inc.header}
<!--tmpl-resource-->
{include app:admin.inc.top}
<link rel="stylesheet" href="/res/js/framework/nestable/nestable.css">
<div class="container-fluid content-body">
	<div class="main">
		<section class="left-section">
			<dl id="leftNav" data-type="order">
				<dt><i class="glyphicon glyphicon-shopping-cart"></i> 交易管理</dt>
				{if in_case_array('admin/order/add',$priv) || empty($priv)}
				<dd><a class="mbh" href="{url /admin/order/add}">添加订单</a></dd>
				{/if}
				{if in_case_array('admin/order',$priv) || empty($priv)}
				<dd><a class="mb active" href="{url /admin/order/index}">订单列表</a></dd>
				{/if}
				{if in_case_array('admin/contract',$priv) || empty($priv)}
				<dd><a class="mbh" href="{url /admin/contract/index}">合同列表</a></dd>
				{/if}
			</dl>
		</section>

		<!-- main content start-->
		<section class="right-section" id="right-section">
			{include admin.inc.bread}
			<h2 class="header">{$title}</h2>
				<div class="inner-container">
					<form class="form-inline search-form" role="form">
						<nav class="inline-form">
							<div class="css-select-group">
								<div class="input-group">
									<div class="input-group-addon">
										订单号
									</div>
									<input type="text" class="form-control input-sm" maxlength="28" placeholder="" name="s_order_no" value="{$s_order_no}">
								</div>
							</div>
							<div class="css-select-group">
								<div class="css-select ">
									<div class="chosen">
										<span></span>
										<i class="angle-down"></i>
										<input type="hidden" name="s_consignee_type" value="{$s_consignee_type}">
									</div>
									<ul>
										<li data-value="0">收货人</li>
										<li data-value="1">提货人</li>
									</ul>
								</div>
								<input type="text" class="form-control input-sm w100" maxlength="{maxlength}" placeholder="" name="s_consignee" value="{$s_consignee}">
							</div>
							<!--<div class="css-select-group">
								<div class="css-select ">
									<div class="chosen">
										<span></span>
										<i class="angle-down"></i>
										<input type="hidden" name="s_contact_type" value="{$s_contact_type}">
									</div>
									<ul>
										<li data-value="0">收货人电话</li>
										<li data-value="1">提货人电话</li>
									</ul>
								</div>
								<input type="text" class="form-control input-sm" maxlength="{maxlength}" placeholder="联系电话" name="s_contact_mobile" value="{$s_contact_mobile}">
							</div>-->
							<div class="form-group">
								<div class="css-select">
									<div class="chosen">
										<span></span>
										<i class="angle-down"></i>
										<input type="hidden" name="s_order_status" value="{$s_order_status}">
									</div>

									<ul>
										<li data-value="all">-订单状态-</li>
										{loop $option_arr $k $v}
										<li data-value="{$k}">{$v}</li>
										{/loop}
									</ul>
								</div>
							</div>
							<div class="css-select-group">
								<div class="css-select">
									<div class="chosen">
										<span></span>
										<i class="angle-down"></i>
										<input type="hidden" name="s_time_type" value="{$s_time_type}">
									</div>

									<ul>
									<li value="0" {if $s_time_type!=1}selected{/if}>下单时间</li>
									<li value="1" {if $s_time_type==1}selected{/if}>付款时间</li>
								</ul>
								</div>
								<div class="input-group">
									<input style="width:100px;" class="form-control form-control-inline input-sm mdate"  size="16" type="text"
									name="s_s_order_time" value="{$s_s_order_time}"
									placeholder="开始时间" />

									<div class="input-group-addon">
										-
									</div>
									<input style="width:100px;" class="form-control form-control-inline input-sm mdate"  size="16" type="text"
									name="s_e_order_time" value="{$s_e_order_time}"
									placeholder="结束时间" />
								</div>
							</div>

							<input type="hidden" name="order" value="{$order}">
							<button type="submit" class="btnlg mb">搜索</button>
							<input type="hidden" name="pagesize" value="{$pagesize}">
							<button type="button" class="btnlg mb" id="J_Export_btn"> 导出Excel</button>
							<button type="button" class="btnlg mb" id="defined">配置列表项</button>
						</nav>
						<!-- search form end -->
					<!--</form>
					<form id="J_List_Form">-->
						<div class="table-responsive">
							<table id="J_ListTable" class="table  table-hover  table-striped">
								<thead>
									<tr>
										<th width="20"><label class="css-checkbox"><input type="checkbox" class="check-all" /><span></span></label></th>
										{loop $custom_field_arr $k $v}
										<th>{$fields_arr[$v]}</th>
										{/loop}
									</tr>
								</thead>
								<tbody>
								{if empty($items)}
								<tr>
									<td style="text-align:center;" colspan="14" class="empty-table-td">{$emptyRecord}</td>
								</tr>
								{/if}
								{loop $items $v}
								<tr>
									<td><label class="css-checkbox"><input type="checkbox" name="ids[]" value="{$v[id]}"/><span></span></label></td>
									{loop $custom_field_arr $value}
									{if $value=='shippingway'}
									<td>{$v[shippingway]}
										(
										{if $v[shipping_way]==$SHIPPING_WAY_BUYER}
										提货人:{$v[shipping_fullname]}&nbsp;
										提货人电话:{$v[shipping_mobile]}
										{else}
										收货人:{$v[consignee]}&nbsp;
										收货人电话:{$v[contact_mobile]}
										{/if}
										)
									</td>
									{else}
									{if $value=='operation'}
									<td>
										<input type="hidden" value="{$v[member_id]}" name="member_id">
										{if in_array('admin/order/detail',$priv) || empty($priv)}
										<a href="{$detail_url}?id={$v[id]}" class="btnsm-success item-bind">
											详情
										</a>
										{/if}
										{if $v[order_status]<=$ORDER_STATUS_UNPAY}
										{if $v[order_status]==$WAIT_FOR_MERCHANT_CONFIRMATION}
										{if in_array('admin/order/merchantConfirmation',$priv) || empty($priv)}
										<a href="javascript:void(0);" data-id="{$v[id]}" class="btnsm-take confirmation">
											确认订单</a>
										{/if}
										{/if}
										{if in_array('admin/order/edit',$priv) || empty($priv)}
										<a href="{$edit_url}?id={$v[id]}" class="btnsm-primary">
											编辑</a>
										{/if}
										{if in_array('admin/order/cancelorder',$priv) || empty($priv)}
										<a href="javascript:void(0);" data-id="{$v[id]}" class="btnsm-danger cancelOrder">
											</i> 取消</a>
										{/if}
										{/if}
										{if ($v[order_status]==$ORDER_STATUS_UNPAY && $v[pay_way]==$PAY_WAY_OFFLINE) || $v[order_status]==$ORDER_PENDING_RECEIPT}
										{if in_array('admin/order/confirmorderpay',$priv) || empty($priv)}
										<a href="javascript:void(0);" data-id="{$v[id]}" class="btnsm-take select_record">
											收款</a>
										{/if}
										{/if}
										{if $v[order_status]==$ORDER_STATUS_TO_BE_SHIPPED}
										{if in_array('admin/order/delivery',$priv) || empty($priv)}
										{if $v[shipping_way]==$SHIPPING_WAY_BUYER}
										<a href="javascript:void(0);" data-id="{$v[id]}" class="btnsm-primary delivery">
											发货
										</a>
										{else}
										<a href="javascript:void(0);" data-id="{$v[id]}" class="btnsm-primary popwin" data-template="content-add-template">
											发货
										</a>
										{/if}
										{/if}
										{/if}
									</td>
									{else}
									<td>{$v[$value]}</td>
									{/if}
									{/if}
									{/loop}
								</tr>
								{/loop}
							</table>
						</div>
					</form>
					<div class="text-right">
						{$pagemenu}
					</div>
				</div>
			</div>
		</section>
	</div>
</div>

<!--footer section start-->
{include admin.inc.footer}
<!--footer section end-->

<!--tmpl-script-->

<!-- template -->
<!--自定义start-->
<script id="defined_table" type="text/html">
	<div>
		<form id="defined_edit" class="form-horizontal">
			<input type="hidden" name="url" value="{$module}/{$action}/{$method}">
			<div class="de_title"><i></i>拖动改变顺序</div>
			<div class="cf">
				<div class="dd" id="nestable3">
					<ol class="dd-list">
						{loop $fields_arr_new $v}
						<li class="dd-item dd3-item" data-id="{$v}">
							<div class="dd-handle dd3-handle"></div><div class="dd3-content">
							<label class="css-checkbox">
								<input type="checkbox" {if in_array($v,$custom_field_arr)}checked="checked"{/if} name="field_arr[]" value="{$v}">
								<span>{$fields_arr[$v]}</span>
							</label>
						</div>
						</li>
						{/loop}
					</ol>
				</div>
			</div>
		</form>
	</div>
</script>
<!--自定义end-->

<script type="text/html" id="content-add-template">
	<div class="pop-layer-box">
		<form role="form" class="content-add-form" id="content-add-form" autocomplete="off">
			<div class="form-group">
				<label><span class="asterisk">*</span>送货人姓名</label>
				<input type="text" name="data[shipping_fullname]" class="form-control" placeholder="送货人姓名" value="" required />
			</div>
			<p class="help-block text-error"></p>

			<div class="form-group">
				<label><span class="asterisk">*</span>送货人手机号码</label>
				<input type="text" name="data[shipping_mobile]" dtype="mobile" class="form-control" placeholder="送货人手机号码" value="" required />
			</div>
			<p class="help-block text-error"></p>

			<div class="form-group">
				<label><span class="asterisk">*</span>送货车辆牌号</label>
				<input type="text" name="data[shipping_car_card]" class="form-control" placeholder="送货车辆牌号" value="" required />
			</div>
			<p class="help-block text-error"></p>

			<div class="form-group">
				<label>送货人身份证</label>
				<input type="text" name="data[shipping_id_card]" class="form-control" maxlength="18" value="" placeholder="送货人身份证" />
			</div>

			<div class="form-group">
				<label><span class="asterisk">*</span>送货日期</label>
				<input style="width:100px;" class="form-control mdate" dtype="time" size="16" type="text"
					   name="data[shipping_time]" value=""
					   placeholder="送货日期" required />
			</div>
			<p class="help-block text-error"></p>

			<div class="form-group">
				<label>发货补充</label>
				<textarea name="data[shipping_remark]" class="form-control"></textarea>
			</div>
			<input type="hidden" name="id" value="{[id]}" />
		</form>
	</div>
</script>

<!-- pagescript -->
<script type="text/javascript">
	seajs.use("admin/trading_orderindex",function (exports){
		exports.init({
			billRecordsUrl : '/admin/order/billRecords',//获取资金流水
			confirmOrderPayUrl : '/admin/order/confirmOrderPay',//确认收款
			addShippingUrl : '/admin/order/delivery',//发货
			merchantConfirmationUrl : '/admin/order/merchantConfirmation',//确认订单
			cancelOrderUrl : '/admin/order/cancelOrder',//取消订单
		});
	});
</script>


<script id="assocpage" type="text/html">
<div class="text-right">
	<ul class="pagination blog-pagination">
		<li><a class="assoc-page" data-page="{[prev]}" href="javascript:void(0);">上一页</a></li> 
		{[loop pages page]}

		<li {[if curr == page]}class="active"{[/if]}><a class="assoc-page" data-page="{[page]}"  href="javascript:void(0)">{[page]}</a></li> 

		{[/loop]}
		<li><a class="assoc-page" href="javascript:void(0);" data-page="{[nexts]}">下一页</a></li> 
	</ul>	
</div>
</script>
</body>
</html>
